@extends('layouts.layouts')
@section('title')
    <title>后台首页</title>
@endsection
@section('content')
    <link rel="stylesheet" href="/lib/layer/theme/default/layer.css"/>
    <script type="text/javascript" src="/lib/layer/layer.js"></script>
    <div class="content">
        <div class="header">
            <ul class="breadcrumb">
                <li><a href="/course/list">课程管理</a></li>
                <li class="active">课程列表</li>
            </ul>
        </div>
        <div class="main-content">
            <div class="btn-toolbar list-toolbar">
                <form class="form-inline" action="" method="get">
                    <a href="/train/course/add"><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" ><i class="fa fa-plus"></i> 新增</button></a>
                    <div class="form-group">
                        <input type="text" class="form-control" name="title" placeholder="课程标题" value="">
                    </div>
                    <button type="submit" class="btn btn-default">筛选</button>
                </form>
            </div>
            <ul class="nav nav-pills">
                <li role="presentation" class=" commonCourse"><a href="/course/list">课程</a></li>
            </ul>
            <div class="row not_live_list" style="">
                <div class="col-sm-12 col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading no-collapse">课程列表</div>
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>课程标题</th>
                                <th>课程作者</th>
                                <th>课程价格</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                @foreach($courseGroups as $group)
                                <tr id="courseClass_">
                                    <td>{{$group->id}}</td>
                                    <td>{{$group->title}}</td>
                                    <td>{{$group->author->name}}</td>
                                    <td>{{$group->price}}</td>
                                    <td class="text-justify" style="width:30%;">
                                        <a class="btn btn-info btn-xs" onclick="courseList(this)" data-id="{{$group->id}}">课程详情</a>
                                        <a class="btn btn-info btn-xs" href="/train/course/buyed?id={{$group->id}}">购课详情</a>
                                        <a class="btn btn-info btn-xs" href="/train/ask/zuoye/{{$group->id}}">作业详情</a>
                                        <a class="btn btn-info btn-xs" href="/train/periods?id={{$group->id}}">期数设置</a>
                                        <a class="btn btn-success btn-xs" href="/train/course/edit?id={{$group->id}}">编辑</a>
                                        <button class="btn btn-danger btn-xs" data-id="" onclick="courseDelete(this)">删除</button>

                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">课程列表</h4>
                </div>
                <div class="modal-body"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var page = 1;
        function courseList(obj){
            var id = $(obj).attr('data-id');
            var data = {id:id,page:page};
            $.ajax({
                url:'/train/course/list',
                data:data,
                type:'GET',
                dataType:'json',
                success:function(res){
                    $('#myModal .modal-body').html(res.body);
                    $('#myModal').modal('show');
                }
            })
        }
    </script>
@endsection